package com.flying;

import org.apache.zookeeper.*;

import java.io.IOException;

public class SelectTest {
    public static void main(String[] args) throws Exception {
//        String ip = "192.168.106.13:2181";
        String ip = "127.0.0.1:2181";
        ZooKeeper zk = new ZooKeeper(ip,
                100000, new Watcher() {
            // 监控所有被触发的事件
            public void process(WatchedEvent event) {
                System.out.println("已经触发了" + event.getType() + "事件！");
            }
        });

//        zk.create("/testRootPath", "testRootData".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
//                CreateMode.PERSISTENT);
////             创建一个子目录节点
//        zk.create("/testRootPath/testChildPathOne", "testChildDataOne".getBytes(),
//                ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

//        System.out.println(new String(zk.getData("/testRootPath", false, null)));
//        zk.close();
        Thread.currentThread().join();
    }
}
